﻿package mortal.game.view.chat
{
    import Message.Game.*;
    import Message.Public.*;
    import __AS3__.vec.*;
    import com.gengine.debug.*;
    import com.gengine.utils.*;
    import extend.language.*;
    import flash.utils.*;
    import mortal.common.global.*;
    import mortal.game.cache.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.manager.msgTip.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.info.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.scene3D.layer3D.utils.*;
    import mortal.game.scene3D.map3D.util.*;
    import mortal.game.utils.*;
    import mortal.game.view.chat.chatPrivate.*;
    import mortal.game.view.chat.chatViewData.*;
    import mortal.game.view.chat.data.*;
    import mortal.game.view.systemSetting.*;
    import mortal.mvc.core.*;
    import mortal.mvc.interfaces.*;

    public class ChatController extends Controller
    {
        private var _chatModule:ChatModule;
        private var _sendItemList:Array;
        private var _sendPetList:Array;
        private var _sendMapPoint:Array;
        private var _lastChatContent:String;
        private var _lastChatRepeatTime:int = 0;
        private var _lastSendItemList:Array;
        private var _lastSendPetList:Array;
        private var _lastChatShowPointList:Array;
        private const chatShowItemMaxNum:int = 3;
        private var haveQQInfoNum:int = 0;

        public function ChatController()
        {
            this._sendItemList = new Array();
            this._sendPetList = new Array();
            this._sendMapPoint = new Array();
            this._lastSendItemList = new Array();
            this._lastSendPetList = new Array();
            this._lastChatShowPointList = new Array();
            return;
        }// end function

        override protected function initView() : IView
        {
            if (this._chatModule == null)
            {
                this._chatModule = new ChatModule();
                this._chatModule.x = 0;
                this._chatModule.layer = LayerManager.uiLayer;
            }
            return this._chatModule;
        }// end function

        override protected function initServer() : void
        {
            Dispatcher.addEventListener(EventName.ChatSend, this.sendChatHandler);
            Dispatcher.addEventListener(EventName.ChatPrivateSend, this.sendchatPrivateHandler);
            Dispatcher.addEventListener(EventName.ChatPrivate, this.chatPrivateHandler);
            Dispatcher.addEventListener(EventName.ChatShowItem, this.chatShowHandler);
            Dispatcher.addEventListener(EventName.ChatShowPet, this.chatShowPetHandler);
            Dispatcher.addEventListener(EventName.ChatShowPoint, this.chatShowPointHandler);
            Dispatcher.addEventListener(EventName.ChatShield, this.shieldHandler);
            Dispatcher.addEventListener(EventName.ChatDice, this.chatDiceHandler);
            Dispatcher.addEventListener(EventName.ChatCopyUpRecord, this.copyUpRecordHandler);
            Dispatcher.addEventListener(EventName.Scene_Update, this.onSceneUpdateHandler);
            NetDispatcher.addCmdListener(ServerCommand.ChatMessageUpdate, this.chatMessageHandler);
            NetDispatcher.addCmdListener(ServerCommand.GetRoleList, this.onMiniPlayerHandler);
            NetDispatcher.addCmdListener(ServerCommand.GroupPlayerInfoChange, this.onGroupChange);
            NetDispatcher.addCmdListener(ServerCommand.GUILD_EXIT, this.onGuildExit);
            return;
        }// end function

        private function copyUpRecordHandler(event:DataEvent) : void
        {
            if (this._lastChatContent)
            {
                this._chatModule.addInputText(this._lastChatContent);
                (view as ChatModule).setChatInputFocus();
                this._sendItemList.splice(0);
                this._sendItemList = this._sendItemList.concat(this._lastSendItemList);
                this._sendPetList.splice(0);
                this._sendPetList = this._sendPetList.concat(this._lastSendPetList);
                this._sendMapPoint.splice(0);
                this._sendMapPoint = this._sendMapPoint.concat(this._lastChatShowPointList);
            }
            return;
        }// end function

        private function chatDiceHandler(event:DataEvent) : void
        {
            GameProxy.chat.SendMessage(EChatType._EChatTypeGuildRoll, "");
            return;
        }// end function

        private function sendChatHandler(event:DataEvent) : void
        {
            var _loc_10:int = 0;
            var _loc_13:Array = null;
            var _loc_14:Array = null;
            var _loc_15:ItemData = null;
            var _loc_16:String = null;
            var _loc_17:String = null;
            var _loc_18:SPet = null;
            var _loc_19:String = null;
            var _loc_20:String = null;
            var _loc_21:ChatShowPoint = null;
            var _loc_22:String = null;
            var _loc_23:SMiniPlayer = null;
            var _loc_24:ChatData = null;
            var _loc_25:SChatMsg = null;
            var _loc_26:String = null;
            var _loc_27:String = null;
            var _loc_28:MsgTypeImpl = null;
            var _loc_29:String = null;
            var _loc_2:Boolean = false;
            var _loc_3:* = event.data;
            var _loc_4:* = _loc_3["area"];
            var _loc_5:* = _loc_3["content"];
            var _loc_6:Boolean = false;
            if (_loc_3["isSystem"])
            {
                _loc_6 = _loc_3["isSystem"];
            }
            if (_loc_3["isHaveMapPoint"])
            {
                _loc_2 = Boolean(_loc_3["isHaveMapPoint"]);
            }
            var _loc_7:uint = 0;
            var _loc_8:* = this.getChatTypeByArea(_loc_4);
            var _loc_9:Array = [];
            if (_loc_3.hasOwnProperty("color"))
            {
                _loc_7 = _loc_3["color"];
            }
            if (Cache.instance.role.entityInfo.level < ParamsConst.instance.chatBaseLevel)
            {
                if (_loc_4 == ChatArea.Team)
                {
                    this.addTipMsg(Language.getStringByParam(11588, ParamsConst.instance.chatBaseLevel.toString()), ChatType.Tips);
                    return;
                }
                if (_loc_4 == ChatArea.World)
                {
                    this.addTipMsg(Language.getStringByParam(11589, ParamsConst.instance.chatBaseLevel.toString()), ChatType.Tips);
                    return;
                }
                if (_loc_4 == ChatArea.Scene)
                {
                    this.addTipMsg(Language.getStringByParam(11590, ParamsConst.instance.chatBaseLevel.toString()), ChatType.Tips, ChatArea.Scene);
                    return;
                }
                if (_loc_4 == ChatArea.Speaker)
                {
                    MsgManager.showRollTipsMsg(Language.getStringByParam(11591, ParamsConst.instance.chatBaseLevel.toString()));
                    return;
                }
            }
            if (_loc_4 == ChatArea.World || _loc_4 == ChatArea.Country || _loc_4 == ChatArea.Union || _loc_4 == ChatArea.Team || _loc_4 == ChatArea.Scene)
            {
                if (this._lastChatContent == _loc_5)
                {
                    var _loc_30:String = this;
                    var _loc_31:* = this._lastChatRepeatTime + 1;
                    _loc_30._lastChatRepeatTime = _loc_31;
                }
                else
                {
                    this._lastChatRepeatTime = 0;
                }
                if (this._lastChatRepeatTime >= 5)
                {
                    this.addTipMsg(Language.getString(11592), ChatType.Tips, _loc_4);
                    (view as ChatModule).clearCD();
                    return;
                }
                this._lastChatContent = _loc_5;
                this._lastSendItemList.splice(0);
                this._lastSendItemList = this._lastSendItemList.concat(this._sendItemList);
                this._lastSendPetList.splice(0);
                this._lastSendPetList = this._lastSendPetList.concat(this._sendPetList);
                this._lastChatShowPointList.splice(0);
                this._lastChatShowPointList = this._lastChatShowPointList.concat(this._sendMapPoint);
            }
            var _loc_11:Boolean = false;
            if (cache.role.entityInfo.level <= ParamsConst.instance.chatLimitLevel)
            {
                if (this.hasUrl(_loc_5))
                {
                    _loc_11 = true;
                }
                else
                {
                    _loc_11 = (_loc_4 == ChatArea.World || _loc_4 == ChatArea.Union || _loc_4 == ChatArea.Speaker) && this.hasQQInfo(_loc_5);
                }
            }
            if (_loc_4 == ChatArea.Team)
            {
                if (!cache.group.isInGroup)
                {
                    MsgManager.showRollTipsMsg(Language.getString(11593));
                    return;
                }
            }
            if (_loc_4 == ChatArea.Union && !cache.guild.selfGuildInfo.selfHasJoinGuild)
            {
                MsgManager.showRollTipsMsg(Language.getString(11594));
                return;
            }
            var _loc_12:int = 0;
            if (_loc_5 != "")
            {
                _loc_13 = new Array();
                _loc_14 = new Array();
                if (this._sendItemList.length > 0)
                {
                    for each (_loc_15 in this._sendItemList)
                    {
                        
                        if (_loc_12 >= this.chatShowItemMaxNum)
                        {
                            break;
                        }
                        _loc_16 = "[" + _loc_15.itemInfo.name + "]";
                        _loc_10 = _loc_5.indexOf(_loc_16);
                        if (_loc_10 >= 0)
                        {
                            _loc_17 = "[" + _loc_15.serverData.posType.toString() + "," + _loc_15.serverData.uid + "]";
                            _loc_5 = _loc_5.replace(_loc_16, _loc_17);
                            _loc_13.push(_loc_15.serverData);
                            _loc_12++;
                        }
                    }
                }
                if (this._sendPetList.length > 0)
                {
                    for each (_loc_18 in this._sendPetList)
                    {
                        
                        if (_loc_12 >= this.chatShowItemMaxNum)
                        {
                            break;
                        }
                        _loc_19 = _loc_18.publicPet.name;
                        _loc_19 = "[" + _loc_19 + "]";
                        _loc_10 = _loc_5.indexOf(_loc_19);
                        if (_loc_10 >= 0)
                        {
                            _loc_20 = "[" + EPlayerItemPosType._EPlayerItemPosTypePet + "," + _loc_18.publicPet.uid + "]";
                            _loc_5 = _loc_5.replace(_loc_19, _loc_20);
                            _loc_14.push(_loc_18);
                            _loc_12++;
                        }
                    }
                }
                if (this._sendMapPoint.length > 0)
                {
                    for each (_loc_21 in this._sendMapPoint)
                    {
                        
                        _loc_22 = _loc_21.mapNameString();
                        if (_loc_22)
                        {
                            _loc_10 = _loc_5.indexOf(_loc_22);
                            if (_loc_10 >= 0)
                            {
                                _loc_2 = true;
                                _loc_5 = _loc_5.replace(_loc_22, _loc_21.mapIdString());
                            }
                        }
                    }
                }
                if (!_loc_2 && _loc_11 || ChatFraudFilter.isChatFraud(_loc_5))
                {
                    _loc_23 = new SMiniPlayer();
                    _loc_23.name = cache.role.entityInfo.name;
                    _loc_23.sex = cache.role.entityInfo.sex;
                    _loc_23.camp = cache.role.entityInfo.camp;
                    _loc_23.career = cache.role.entityInfo.career;
                    _loc_23.level = cache.role.entityInfo.level;
                    _loc_23.entityId = cache.role.entityInfo.entityId;
                    _loc_24 = new ChatData();
                    _loc_25 = new SChatMsg();
                    _loc_25.fromPlayer = _loc_23;
                    _loc_25.chatType = _loc_8;
                    _loc_25.content = _loc_5;
                    _loc_25.chatDt = new Date();
                    _loc_26 = Cache.instance.platform.qqPlatJs;
                    if (_loc_26)
                    {
                        _loc_25.jsStr = _loc_26;
                    }
                    _loc_24.copyFromChatMsg(_loc_25);
                    if (_loc_8 == EChatType._EChatTypeGuild)
                    {
                        ChatManager.addGuildWindow();
                        ChatManager.addGuildMessage(_loc_24);
                    }
                    (view as ChatModule).updateChatMesssage(_loc_24);
                    (view as ChatModule).clearInput();
                    this._sendItemList = new Array();
                    this._sendPetList = new Array();
                    this._sendMapPoint = new Array();
                    if (_loc_8 == EChatType._EChatTypeTrumpet)
                    {
                        _loc_27 = "0xFFCC00";
                        if (_loc_7)
                        {
                            _loc_29 = _loc_7.toString(16);
                            _loc_27 = "0x" + _loc_29.substring(2);
                        }
                        _loc_28 = new MsgTypeImpl(null, _loc_27, 15000);
                        MsgManager.addSpeakerText(_loc_23, _loc_5, _loc_28);
                    }
                    return;
                }
                GameProxy.chat.SendMessage(_loc_8, _loc_5, _loc_7, _loc_13, _loc_14, _loc_9, _loc_6);
                (view as ChatModule).clearInput();
                this._sendItemList = new Array();
                this._sendPetList = new Array();
                this._sendMapPoint = new Array();
            }
            return;
        }// end function

        private function chatShowHandler(event:DataEvent) : void
        {
            var _loc_2:* = event.data as ItemData;
            if (ItemsUtil.isOwnItem(_loc_2))
            {
                this._sendItemList.push(_loc_2);
                (view as ChatModule).addInputText("[" + _loc_2.itemInfo.name + "]");
                (view as ChatModule).setChatInputFocus();
            }
            return;
        }// end function

        private function chatShowPetHandler(event:DataEvent) : void
        {
            var _loc_2:* = event.data as SPet;
            this._sendPetList.push(_loc_2);
            var _loc_3:* = _loc_2.publicPet.name;
            _loc_3 = "[" + _loc_3 + "]";
            (view as ChatModule).addInputText(_loc_3);
            (view as ChatModule).setChatInputFocus();
            return;
        }// end function

        private function chatShowPointHandler(event:DataEvent) : void
        {
            var _loc_2:* = event.data as ChatShowPoint;
            this._sendMapPoint.push(_loc_2);
            return;
        }// end function

        private function shieldHandler(event:DataEvent) : void
        {
            var _loc_2:* = event.data["isShield"];
            var _loc_3:* = event.data["label"];
            var _loc_4:* = Language.getStringByParam(11595, _loc_3);
            if (!_loc_2)
            {
                _loc_4 = Language.getStringByParam(11596, _loc_3);
            }
            this.addTipMsg(_loc_4, ChatType.System, ChatMessageWorking.getNameByLabel(_loc_3));
            return;
        }// end function

        public function addGuildRedPackMsg(param1:SRedEnvelopeInfo) : void
        {
            var _loc_2:* = new SChatMsg();
            _loc_2.fromPlayer = param1.boss;
            var _loc_3:String = "";
            if (param1.type == 0)
            {
                _loc_3 = Language.getStringByParam(11597, param1.boss.name, param1.redId.toString(), param1.boss.name);
            }
            else if (param1.type == 1)
            {
                _loc_3 = Language.getStringByParam(11598, param1.boss.name, param1.totalMoney.toString(), param1.redId.toString(), param1.boss.name);
            }
            else if (param1.type == 2)
            {
                _loc_3 = Language.getStringByParam(35637, param1.boss.name, param1.redId.toString(), param1.boss.name);
                this.addTypeRumorMsg(_loc_3, [], ChatType.Legent);
                return;
            }
            _loc_2.content = _loc_3;
            _loc_2.chatDt = ClockManager.instance.nowDate;
            _loc_2.font = 0;
            _loc_2.chatType = EChatType._EChatTypeGuild;
            var _loc_4:* = new ChatData();
            _loc_4.copyFromChatMsg(_loc_2);
            _loc_4.guildPost = int(param1.bossPosition);
            _loc_4.alyzType = 1;
            if (!SystemSetting.instance.isHideGuildChatPanel.bValue)
            {
                ChatManager.addGuildWindow();
                ChatManager.addGuildMessage(_loc_4);
                if (param1.type == 0)
                {
                    ChatManager.guildWindow.setTopTipHtmlText(Language.getStringByParam(21370, param1.boss.name), param1);
                }
                else if (param1.type == 1)
                {
                    ChatManager.guildWindow.setTopTipHtmlText(Language.getStringByParam(21370, param1.boss.name, param1.totalMoney), param1);
                }
            }
            (view as ChatModule).updateChatMesssage(_loc_4);
            return;
        }// end function

        private function chatMessageHandler(param1:Object) : void
        {
            var _loc_16:String = null;
            var _loc_17:MsgTypeImpl = null;
            var _loc_18:String = null;
            var _loc_19:int = 0;
            var _loc_20:Vector.<ChatCellData> = null;
            var _loc_21:String = null;
            var _loc_22:int = 0;
            var _loc_23:Boolean = false;
            var _loc_24:Boolean = false;
            var _loc_25:Boolean = false;
            var _loc_2:* = getTimer();
            var _loc_3:* = param1 as SChatMsg;
            _loc_3.content = ChatFraudFilter.replaceSecialNumSymbols(_loc_3.content);
            var _loc_4:* = _loc_3.chatType;
            var _loc_5:* = _loc_3.font;
            var _loc_6:* = _loc_3.fromPlayer;
            var _loc_7:* = new Array();
            var _loc_8:* = _loc_3.pets;
            var _loc_9:* = _loc_3.chatDt;
            var _loc_10:* = new ChatData();
            _loc_10.copyFromChatMsg(_loc_3);
            var _loc_11:* = cache.friend.findRecordByRoleId(_loc_6.entityId.id, EFriendFlag._EFriendFlagBlackList) ? (true) : (false);
            var _loc_12:* = ClientSetting.local.getIsDone(IsDoneType.RefuseStranger);
            if (_loc_11)
            {
                return;
            }
            if (_loc_4 == EChatType._EChatTypeTrumpet || _loc_4 == EChatType._EChatTypeCrossTrumpet)
            {
                _loc_16 = "0xFFCC00";
                if (_loc_5)
                {
                    _loc_18 = _loc_5.toString(16);
                    _loc_16 = "0x" + _loc_18.substring(2);
                }
                _loc_17 = new MsgTypeImpl(null, _loc_16, 15000);
                MsgManager.addSpeakerText(_loc_6, _loc_3.content, _loc_17);
            }
            var _loc_13:* = cache.role.entityInfo.name;
            var _loc_14:* = cache.friend.findRecordByRoleId(_loc_6.entityId.id, EFriendFlag._EFriendFlagFriend) ? (true) : (false);
            if (_loc_4 == EChatType._EChatTypePrivate && !(_loc_12 && (_loc_6.entityId.id != cache.role.entityInfo.entityId.id && !_loc_14)))
            {
                if (_loc_13 != _loc_6.name && _loc_13 != _loc_3.toPlayer)
                {
                    return;
                }
                if (!EntityUtil.equal(cache.role.entityInfo.entityId, _loc_6.entityId))
                {
                    if (!cache.friend.isRecent(_loc_6.entityId.id))
                    {
                        cache.friend.addToRecent(_loc_6);
                    }
                    ChatManager.addWindow(_loc_6);
                    ChatManager.addMessage(_loc_10);
                }
                else
                {
                    if (!cache.friend.isRecent(_loc_3.toEntityId.id))
                    {
                        GameProxy.player.findMiniPlayerById([_loc_3.toEntityId.id], 1);
                    }
                    ChatManager.addMessage(_loc_10);
                }
            }
            if (_loc_3.items && _loc_3.items.length >= 0)
            {
                _loc_19 = 0;
                while (_loc_19 < _loc_3.items.length)
                {
                    
                    _loc_7.push(new ItemData(_loc_3.items[_loc_19] as SPlayerItem));
                    _loc_19++;
                }
            }
            _loc_10.itemList = _loc_7;
            _loc_10.petList = _loc_8;
            var _loc_15:* = _loc_10.typeArea;
            if (_loc_15 == ChatArea.Scene || _loc_15 == ChatArea.Team)
            {
                _loc_20 = ChatMessageWorking.getCellDatas(_loc_10);
                _loc_21 = "";
                _loc_22 = 0;
                while (_loc_22 < _loc_20.length)
                {
                    
                    _loc_21 = _loc_21 + _loc_20[_loc_22].text;
                    _loc_22++;
                }
                _loc_23 = _loc_15 == ChatArea.Scene;
                _loc_24 = EntityUtil.isSameServerByRole(_loc_6.entityId);
                _loc_25 = EntityUtil.isSameProxyByRole(_loc_6.entityId);
                if (_loc_23)
                {
                    if ((GameMapUtil.curMapState.isArenaCopy || GameMapUtil.curMapState.isBattlefield || cache.group.isInCopyGroup || GameMapUtil.curMapState.isHeroArenaMap) && !_loc_25)
                    {
                        return;
                    }
                    if (!_loc_24)
                    {
                        return;
                    }
                }
                LayerManager.entityTalkLayer.addTalk(ThingUtil.entityUtil.getEntity(_loc_6.entityId), _loc_21);
                if (_loc_15 == ChatArea.Team)
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.ChatTeamTalk, {entityId:_loc_6.entityId, content:_loc_21}));
                }
            }
            if (!(_loc_15 == ChatArea.Country && _loc_6.camp != cache.role.entityInfo.camp))
            {
                if (_loc_15 == ChatArea.Union && !SystemSetting.instance.isHideGuildChatPanel.bValue)
                {
                    ChatManager.addGuildWindow();
                    ChatManager.addGuildMessage(_loc_10);
                }
                if (_loc_3.chatType != EChatType._EChatTypeGuildRoll && _loc_3.chatType != EChatType._EChatTypeGuildBattle)
                {
                    (view as ChatModule).updateChatMesssage(_loc_10);
                }
            }
            Log.system(getTimer() - _loc_2);
            return;
        }// end function

        private function hasQQInfo(param1:String) : Boolean
        {
            var _loc_2:* = ChatFraudFilter.delSpecialSymbols(param1);
            if (_loc_2.length >= ParamsConst.instance.chatNumLimit)
            {
                return true;
            }
            return false;
        }// end function

        private function hasSpeicalQQInfo(param1:String) : Boolean
        {
            var _loc_2:* = ChatFraudFilter.delSpecialSymbols(param1);
            if (_loc_2.length >= ParamsConst.instance.chatNumLimit)
            {
                return true;
            }
            return false;
        }// end function

        private function hasUrl(param1:String) : Boolean
        {
            var _loc_2:RegExp = null;
            param1 = param1.replace(/\s""\s/g, "");
            if (param1.length > 20)
            {
                _loc_2 = /(http|https|ftp|file)?([:\/]*)([\w-]{2,}\.)+([A-Za-z]{2,6})+""(http|https|ftp|file)?([:\/]*)([\w-]{2,}\.)+([A-Za-z]{2,6})+/ig;
                return _loc_2.test(param1);
            }
            return false;
        }// end function

        private function getChatTypeByArea(param1:String) : int
        {
            var _loc_2:* = EChatType._EChatTypeWorld;
            switch(param1)
            {
                case ChatArea.World:
                {
                    _loc_2 = EChatType._EChatTypeWorld;
                    break;
                }
                case ChatArea.Country:
                {
                    _loc_2 = EChatType._EChatTypeCamp;
                    break;
                }
                case ChatArea.Scene:
                {
                    _loc_2 = EChatType._EChatTypeSpace;
                    break;
                }
                case ChatArea.Union:
                {
                    _loc_2 = EChatType._EChatTypeGuild;
                    break;
                }
                case ChatArea.Team:
                {
                    _loc_2 = EChatType._EChatTypeTeam;
                    break;
                }
                case ChatArea.Secret:
                {
                    _loc_2 = EChatType._EChatTypePrivate;
                    break;
                }
                case ChatArea.Speaker:
                {
                    _loc_2 = EChatType._EChatTypeTrumpet;
                    break;
                }
                case ChatArea.CrossSpeaker:
                {
                    _loc_2 = EChatType._EChatTypeCrossTrumpet;
                    break;
                }
                case ChatArea.Force:
                {
                    _loc_2 = EChatType._EChatTypeForce;
                    break;
                }
                default:
                {
                    break;
                }
            }
            return _loc_2;
        }// end function

        public function addTipMsg(param1:Object, param2:String, param3:String = "world", param4:int = 0, param5:Array = null, param6:int = 16735067) : void
        {
            switch(param2)
            {
                case ChatType.System:
                case ChatType.Tips:
                case ChatType.Union:
                case ChatType.State:
                case ChatType.Scene:
                case ChatType.Force:
                case ChatType.World:
                case ChatType.CrossServer:
                {
                    (view as ChatModule).updateTipMsg(param2, param1 as String, param3, param4, param5, param6);
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        public function addBackStageMsg(param1:String, param2:Array = null) : void
        {
            if (!param2)
            {
                param2 = [];
            }
            (view as ChatModule).updateTipMsg(ChatType.System, param1, ChatArea.Complex, 1, param2);
            return;
        }// end function

        public function addTypeRumorMsg(param1:String, param2:Array, param3:String = null) : void
        {
            if (!param3)
            {
                param3 = ChatType.Legent;
            }
            if (!SystemSetting.instance.isHideRumorTips.bValue || param3 != ChatType.Legent)
            {
                (view as ChatModule).addRumorMsg(param1, param2, param3);
            }
            return;
        }// end function

        public function addCopyMsg(param1:String, param2:Array) : void
        {
            if (!cache.group.players.length)
            {
                (view as ChatModule).addCopyMsg(param1, param2);
            }
            return;
        }// end function

        private function chatPrivateHandler(event:DataEvent) : void
        {
            var _loc_2:* = event.data as SMiniPlayer;
            if (EntityUtil.equal(_loc_2.entityId, cache.role.entityInfo.entityId))
            {
                return;
            }
            var _loc_3:* = ChatManager.addWindow(_loc_2);
            _loc_3.show();
            _loc_3.inputText.setFocus();
            if (_loc_2 is MiniPlayerInfo)
            {
                if ((_loc_2 as MiniPlayerInfo).defaultChatText)
                {
                    _loc_3.inputText.text = (_loc_2 as MiniPlayerInfo).defaultChatText;
                    _loc_3.inputText.textField.setSelection(0, _loc_3.inputText.text.length);
                }
            }
            if (EntityUtil.isSameServerByRole(_loc_2.entityId))
            {
                GameProxy.player.findMiniPlayerById([_loc_2.entityId.id]);
            }
            return;
        }// end function

        private function onMiniPlayerHandler(param1:Array) : void
        {
            var _loc_2:SMiniPlayer = null;
            if (param1 && param1.length != 0)
            {
                _loc_2 = param1[0];
                ChatManager.updateMiniPlayer(_loc_2);
            }
            return;
        }// end function

        private function sendchatPrivateHandler(event:DataEvent) : void
        {
            var _loc_9:SMiniPlayer = null;
            var _loc_10:SChatMsg = null;
            var _loc_11:ChatShowPoint = null;
            var _loc_12:String = null;
            var _loc_13:int = 0;
            var _loc_2:* = event.data;
            var _loc_3:* = _loc_2["content"];
            var _loc_4:* = _loc_2["toPlayer"];
            var _loc_5:* = _loc_2["color"];
            var _loc_6:* = Boolean(_loc_2["isHasMapPoint"]);
            if (cache.role.entityInfo.level < ParamsConst.instance.chatBaseLevel)
            {
                MsgManager.showRollTipsMsg(Language.getStringByParam(11599, ParamsConst.instance.chatBaseLevel.toString()));
                return;
            }
            var _loc_7:Boolean = false;
            if (this._sendMapPoint.length > 0)
            {
                for each (_loc_11 in this._sendMapPoint)
                {
                    
                    _loc_12 = _loc_11.mapNameString();
                    if (_loc_12)
                    {
                        _loc_13 = _loc_3.indexOf(_loc_12);
                        if (_loc_13 >= 0)
                        {
                            _loc_7 = true;
                            _loc_3 = _loc_3.replace(_loc_12, _loc_11.mapIdString());
                        }
                    }
                }
            }
            var _loc_8:Boolean = false;
            if (!_loc_6 && cache.role.entityInfo.level <= ParamsConst.instance.chatLimitLevel)
            {
                _loc_8 = this.hasQQInfo(_loc_3);
            }
            if (_loc_8 || ChatFraudFilter.isChatFraud(_loc_3))
            {
                _loc_9 = new SMiniPlayer();
                _loc_9.name = cache.role.entityInfo.name;
                _loc_9.sex = cache.role.entityInfo.sex;
                _loc_9.camp = cache.role.entityInfo.camp;
                _loc_9.career = cache.role.entityInfo.career;
                _loc_9.level = cache.role.entityInfo.level;
                _loc_9.entityId = cache.role.entityInfo.entityId;
                _loc_10 = new SChatMsg();
                _loc_10.chatDt = ClockManager.instance.nowDate;
                _loc_10.font = _loc_5;
                _loc_10.fromPlayer = _loc_9;
                _loc_10.chatType = EChatType._EChatTypePrivate;
                _loc_10.content = _loc_3;
                _loc_10.toEntityId = _loc_4.entityId;
                _loc_10.toPlayer = _loc_4.name;
                this.chatMessageHandler(_loc_10);
                return;
            }
            _loc_10 = new SChatMsg();
            _loc_10.chatDt = ClockManager.instance.nowDate;
            _loc_10.toEntityId = _loc_4.entityId;
            _loc_10.content = _loc_3;
            _loc_10.font = _loc_5;
            _loc_10.toPlayer = _loc_4.name;
            _loc_10.chatType = EChatType._EChatTypePrivate;
            _loc_9 = new SMiniPlayer();
            _loc_9.entityId = new SEntityId();
            _loc_10.fromPlayer = _loc_9;
            GameProxy.chat.SendMessageByStruct(_loc_10);
            return;
        }// end function

        private function onGroupChange(param1:Object) : void
        {
            (view as ChatModule).changeTabBar();
            return;
        }// end function

        private function onGuildExit(param1:Object = null) : void
        {
            ChatManager.exitGuild();
            return;
        }// end function

        private function onSceneUpdateHandler(event:DataEvent) : void
        {
            (view as ChatModule).changeTabBar();
            return;
        }// end function

    }
}
